﻿using System.Collections.Generic;
using System.Web;
using Wedn.Core.Utility;

namespace Wedn.Core.Service
{
    /// <summary>
    /// 全局静态缓存配置类, 用于维持配置信息
    /// </summary>
    public class Setting
    {
        //private static Dictionary<string, object> dict;
        /// <summary>
        /// 配置信息数据字典
        /// </summary>
        public static Dictionary<string, object> Dict
        {
            get
            {
                if (HttpRuntime.Cache[Config.SitePrefix + "Setting"] == null)
                {
                    HttpRuntime.Cache[Config.SitePrefix + "Setting"] = new OptionManager().GetDict(null);
                }
                return HttpRuntime.Cache[Config.SitePrefix + "Setting"] as Dictionary<string, object>;
            }
        }
        /// <summary>
        /// 配置信息数据字典
        /// </summary>
        /// <param name="key">键(忽略大小写)</param>
        /// <returns>值</returns>
        public static string GetValue(string key)
        {
            return Dict[key.ToLower()].ToString();
        }
        /// <summary>
        /// 站点URL
        /// </summary>
        public static string SiteUrl { get { return Dict["site_url"].ToString(); } }
        /// <summary>
        /// 站点名称
        /// </summary>
        public static string SiteName { get { return Dict["site_name"].ToString(); } }
        /// <summary>
        /// 站点描述
        /// </summary>
        public static string SiteDescription { get { return Dict["site_description"].ToString(); } }
        /// <summary>
        /// 站点状态
        /// </summary>
        public static string SiteStatus { get { return Dict["site_status"].ToString(); } }
        /// <summary>
        /// 站点状态
        /// </summary>
        public static string SiteViewCount { get { return Dict["site_view_count"].ToString(); } }
        /// <summary>
        /// 站点状态
        /// </summary>
        public static string SitePostCount { get { return Dict["site_post_count"].ToString(); } }
        /// <summary>
        /// 站点状态
        /// </summary>
        public static string SiteCommentCount { get { return Dict["site_comment_count"].ToString(); } }
        /// <summary>
        /// 站点图标
        /// </summary>
        public static string SiteFavicon { get { return Dict["site_favicon"].ToString(); } }
        /// <summary>
        /// 备案ICP
        /// </summary>
        public static string SiteICP { get { return Dict["site_icp"].ToString(); } }
        /// <summary>
        /// 当前程序版本号
        /// </summary>
        public static string Version { get { return Dict["version"].ToString(); } }
        /// <summary>
        /// META关键字
        /// </summary>
        public static string MetaKeywords { get { return Dict["meta_keywords"].ToString(); } }
        /// <summary>
        /// META描述
        /// </summary>
        public static string MetaDescription { get { return Dict["meta_description"].ToString(); } }
        /// <summary>
        /// META作者
        /// </summary>
        public static string MetaAuthor { get { return Dict["meta_author"].ToString(); } }
        /// <summary>
        /// 版权声明
        /// </summary>
        public static string Copyright { get { return Dict["copyright"].ToString(); } }
        /// <summary>
        /// 用户头像显示类型
        /// </summary>
        public static string UserAvatar { get { return Dict["user_avatar"].ToString(); } }
        /// <summary>
        /// 电脑端主题设置
        /// </summary>
        public static string Theme { get { return Dict["theme"].ToString(); } }
        /// <summary>
        /// 手机端主题设置
        /// </summary>
        public static string MobileTheme { get { return Dict["mobile_theme"].ToString(); } }
        /// <summary>
        /// 首页显示文章类型
        /// </summary>
        public static string PostShowType { get { return Dict["post_show_type"].ToString(); } }
        /// <summary>
        /// RSS显示文章类型
        /// </summary>
        public static string RssShowType { get { return Dict["rss_show_type"].ToString(); } }
        /// <summary>
        /// 站点评论状态
        /// </summary>
        public static string CommentStatus { get { return Dict["comment_status"].ToString(); } }
        /// <summary>
        /// 缓存文章条数
        /// </summary>
        public static string PostCacheSize { get { return Dict["post_cache_size"].ToString(); } }
        /// <summary>
        /// 分页显示条数
        /// </summary>
        public static string PageSize { get { return Dict["page_size"].ToString(); } }
        /// <summary>
        /// 边栏小工具
        /// </summary>
        public static string Wedgets { get { return Dict["wedgets"].ToString(); } }
        /// <summary>
        /// 全局伪静态拓展名
        /// </summary>
        public static string RewriteExtension { get { return Dict["rewrite_extension"].ToString(); } }
        /// <summary>
        /// 全局固定连接
        /// </summary>
        public static string Permalink { get { return Dict["permalink"].ToString(); } }
        /// <summary>
        /// 全局垃圾词汇
        /// </summary>
        public static string CommentSpamWords { get { return Dict["comment_spam_words"].ToString(); } }
        /// <summary>
        /// 站长统计代码
        /// </summary>
        public static string StatisticCode { get { return Dict["statistic_code"].ToString(); } }
        //public static string SiteUrl { get { return Dict["smtp_email"].ToString(); } }
        //public static string SiteUrl { get { return Dict["smtp_server"].ToString(); } }
        //public static string SiteUrl { get { return Dict["smtp_server_port"].ToString(); } }
        //public static string SiteUrl { get { return Dict["smtp_username"].ToString(); } }
        /// <summary>
        /// SMTP邮件账户密码
        /// </summary>
        //public static string SiteUrl { get { return Dict["smtp_password"].ToString(); } }
        //public static string SiteUrl { get { return Dict["smtp_enable_ssl"].ToString(); } }
    }
}
